package com.annotation.entities;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.MessageSource;
import org.springframework.context.MessageSourceAware;
import org.springframework.core.env.Environment;

public class Red implements ApplicationContextAware ,MessageSourceAware {

    @Autowired
    private ApplicationContext applicationContext;

    @Autowired(required = false)
    private Environment environment;

    public void printEnvironment(){
        System.out.println(environment.getProperty("os.name"));
    }

    public void printApplicationContext(){
        System.out.println(applicationContext);
    }

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
//        this.applicationContext = applicationContext;
        System.out.println("Red ApplicationContextAware");
    }

    @Override
    public void setMessageSource(MessageSource messageSource) {

    }
}
